package model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.*;

@Entity
@IdClass(model.PrimaryKeyShare.class)
public class Share implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// identifiant du partage crée dans le téléphone utilisateur
	@Id
	int idShareOnPhone;

	// identifiant de l'utilsateur qui envoie un partage
	@Id
	int idSender;

	// relation many to many un partage peut être associe a plusieurs
	// utilisateurs
	@ManyToMany(targetEntity = model.ShareUser.class)
	private List<ShareUser> receiver;

	// identifiant de celui qui emet le partage
	@ManyToOne
	private ShareUser sender;

	// identifiant du fichier du partage
	@OneToOne
	File file;

	// nom du partage
	String nameShare;

	// date de creation
	long dateCreationShare;

	// date de dernière modification
	long dateLastModificationShare;

	/**
	 * @param idShareOnPhone
	 * @param idSender
	 * @param receiver
	 * @param sender
	 * @param file
	 * @param nameShare
	 * @param dateCreationShare
	 * @param dateLastModificationShare
	 */
	public Share(int idShareOnPhone, int idSender, List<ShareUser> receiver,
			ShareUser sender, File file, String nameShare,
			long dateCreationShare, long dateLastModificationShare) {
		super();
		this.idShareOnPhone = idShareOnPhone;
		this.idSender = idSender;
		this.receiver = receiver;
		this.sender = sender;
		this.file = file;
		this.nameShare = nameShare;
		this.dateCreationShare = dateCreationShare;
		this.dateLastModificationShare = dateLastModificationShare;
	}

	public long getDateCreationShare() {
		return dateCreationShare;
	}

	public void setDateCreationShare(long dateCreationShare) {
		this.dateCreationShare = dateCreationShare;
	}

	public long getDateLastModificationShare() {
		return dateLastModificationShare;
	}

	public void setDateLastModificationShare(long dateLastModificationShare) {
		this.dateLastModificationShare = dateLastModificationShare;
	}

	public Share() {
		super();
		// TODO Auto-generated constructor stub
	}

	public int getIdShareOnPhone() {
		return idShareOnPhone;
	}

	public void setIdShareOnPhone(int idShareOnPhone) {
		this.idShareOnPhone = idShareOnPhone;
	}

	public int getIdSender() {
		return idSender;
	}

	public void setIdSender(int idSender) {
		this.idSender = idSender;
	}

	public List<ShareUser> getReceiver() {
		return receiver;
	}

	public void setReceiver(List<ShareUser> receiver) {
		this.receiver = receiver;
	}

	public ShareUser getSender() {
		return sender;
	}

	public void setSender(ShareUser sender) {
		this.sender = sender;
	}

	public File getFile() {
		return file;
	}

	public void setFile(File file) {
		this.file = file;
	}

	public String getNameShare() {
		return nameShare;
	}

	public void setNameShare(String nameShare) {
		this.nameShare = nameShare;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public int hashCode() {
		int result = 1;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		return true;
	}

}
